********* FINAL CODE ***********
use immigration_data.dta, clear****DEFINING ECONOMIC THREAT******g employed2 = employed==1g notemployed = employed2==0g techworker4 = techwork==1|engspecific!=""g danger = keepjob<2 if keepjob!=.g techworker4_danger = techworker4&keepjob<2g techworker4_nondanger = techworker4&keepjob>1g group = .recode group (.=1) if employed2==0recode group (.=2) if techworker4==1&employed2==1recode group (.=3) if techworker4==0&employed2==1tab group, gen(groupcat)******PLACEBO ECONOMIC GROUP*******g lawfinance = (lawspecific!=""|financespecific!=""|realestatespecific!="")&techworker4!=1g group_placz2 = .recode group_placz2 (.=1) if employed2==0recode group_placz2 (.=2) if lawfinance==1&techworker4==0&employed2==1recode group_placz2 (.=3) if lawfinance==0&techworker4==1&employed2==1recode group_placz2 (.=4) if lawfinance==0&techworker4==0&employed2==1tab group_placz2, gen(group_placzcat2)******DEFINING CULTURAL THREAT*****su dscore if race!=4, detailg mediat = dscore>.5691 if dscore!=.g capable_indian2 = capable_indian recode capable_indian2 (0=4) (1=3) (2=2) (3=1) (4=0) (99=.)g polite_indian2 = polite_indianrecode polite_indian2 (0=4) (1=3) (2=2) (3=1) (4=0) (99=.)g hardworking_indian2 = hardworking_indianrecode hardworking_indian2 (0=4) (1=3) (2=2) (3=1) (4=0) (99=.)g hygienic_indian2 = hygienic_indianrecode hygienic_indian2 (0=4) (1=3) (2=2) (3=1) (4=0) (99=.)g trustworthy_indian2 = trustworthy_indianrecode trustworthy_indian2 (0=4) (1=3) (2=2) (3=1) (4=0) (99=.)g indian_traits = (capable_indian2+polite_indian2 +hardworking_indian2 + hygienic_indian2 +trustworthy_indian2)/20g indian_traits_nonwork = (polite_indian2 +hygienic_indian2 +trustworthy_indian2)/12g indian_traits_work2 = (capable_indian2 +hardworking_indian2)/8alpha capable_indian polite_indian hardworking_indian hygienic_indian trustworthy_indian if indian_traits!=.&dscore!=.&race!=4g threatened2 = threatened/4g medthreatened2 = threatened2>.5 if threatened2!=.g medtrait = indian_traits>.35 if indian_traits!=.g medtrait_nonwork = indian_traits_nonwork> .4166667  if indian_traits_nonwork!=.g medtrait_work2 = indian_traits_work2>.25 if indian_traits_work2!=.g dscore2 = (dscore + .9926925)/2.645945pwcorr dscore2 indian_traits if race!=4, sigpwcorr dscore2 threatened2 if race!=4, sig*******DEMOGRAPHIC CONTROLS**************g female = genderg age = 2009-birthyearrecode age (109 = 90)replace age = (age-18)/72g married = maritalstatus==4g pid = partyid/5g educ = education/5 g racewhite = race==8g income2 = income/9 if income<10&income!=.*******DEPENDENT VARIABLES******g h1bvisas_scale = (h1bvisas-1)/4 if h1bvisas!=.g indianimmig_scale = (indianimmig-1)/4 if indianimmig!=.*******RELATIONSHIP BETWEEN ECONOMIC & CULTURAL THREAT*******ttest dscore2 if dscore2!=.&race!=4&zipcode!=., by(techworker4) unequal
ttest threatened2 if dscore2!=.&race!=4&zipcode!=., by(techworker4) unequalttest indian_traits if dscore2!=.&race!=4&zipcode!=., by(techworker4) unequalttest h1bvisas_scale if dscore2!=.&race!=4&zipcode!=., by(techworker4) unequal
ttest dscore2 if dscore!=.&race!=4&(group_placz2==3|group_placz2==2)&zipcode!=., by(group_placz2) unequal
ttest indian_traits if dscore!=.&race!=4&(group_placz2==3|group_placz2==2)&zipcode!=., by(group_placz2) unequal

g college = education>3 if education!=.
ttest education if dscore!=.&race!=4&(group_placz2==3|group_placz2==2)&zipcode!=., by(group_placz2) unequal
ttest college if dscore!=.&race!=4&(group_placz2==3|group_placz2==2)&zipcode!=., by(group_placz2) unequal
ttest income2 if dscore!=.&race!=4&(group_placz2==3|group_placz2==2)&zipcode!=., by(group_placz2) unequal
*******DIFFERENCE-OF-MEANS: H1B VISA SCALE*******
ttest h1bvisas_scale if dscore!=.&race!=4&(group_placz2==3|group_placz2==1)&zipcode!=., by(group_placz2) unequalttest h1bvisas_scale if dscore!=.&race!=4&(group_placz2==3|group_placz2==2)&zipcode!=., by(group_placz2) unequalttest h1bvisas_scale if dscore!=.&race!=4&(group_placz2==3|group_placz2==4)&zipcode!=., by(group_placz2) unequalttest h1bvisas_scale if dscore!=.&race!=4&(group_placz2==3|group_placz2==1)&mediat==0&zipcode!=., by(group_placz2) unequalttest h1bvisas_scale if dscore!=.&race!=4&(group_placz2==3|group_placz2==2)&mediat==0&zipcode!=., by(group_placz2) unequalttest h1bvisas_scale if dscore!=.&race!=4&(group_placz2==3|group_placz2==4)&mediat==0&zipcode!=., by(group_placz2) unequalttest h1bvisas_scale if dscore!=.&race!=4&zipcode!=., by(mediat) unequalttest h1bvisas_scale if techworker4==0&dscore!=.&race!=4&zipcode!=., by(mediat) unequalg group2 = .recode group2 (.=1) if employed2==0recode group2 (.=2) if techworker4==1&techworker4_danger==1&employed2==1recode group2 (.=3) if techworker4==1&techworker4_nondanger==1&employed2==1recode group2 (.=4) if lawfinance==1&techworker4==0&employed2==1recode group2 (.=5) if lawfinance==0&techworker4==0&employed2==1ttest h1bvisas_scale if dscore!=.&race!=4&(group2==2|group2==1), by(group2) unequalttest h1bvisas_scale if dscore!=.&race!=4&(group2==2|group2==4), by(group2) unequalttest h1bvisas_scale if dscore!=.&race!=4&(group2==2|group2==5), by(group2) unequalg group3 = .recode group3 (.=1) if employed2==0recode group3 (.=2) if techworker4==1&techworker4_danger==1&employed2==1recode group3 (.=3) if techworker4==1&techworker4_nondanger==1&employed2==1recode group3 (.=4) if lawfinance==1&techworker4==0&employed2==1&danger==0recode group3 (.=5) if lawfinance==0&techworker4==0&employed2==1&danger==0recode group3 (.=6) if lawfinance==1&techworker4==0&employed2==1&danger==1recode group3 (.=7) if lawfinance==0&techworker4==0&employed2==1&danger==1ttest h1bvisas_scale if dscore!=.&race!=4&(group3==2|group3==6)&zipcode!=., by(group3) unequalttest h1bvisas_scale if dscore!=.&race!=4&(group3==2|group3==7)&zipcode!=., by(group3) unequalttest h1bvisas_scale if dscore!=.&race!=4&(group3==3|group3==1)&zipcode!=., by(group3) unequalttest h1bvisas_scale if dscore!=.&race!=4&(group3==3|group3==4)&zipcode!=., by(group3) unequalttest h1bvisas_scale if dscore!=.&race!=4&(group3==3|group3==5)&zipcode!=., by(group3) unequalg group4 = .recode group4 (.=1) if employed2==0recode group4 (.=2) if techworker4==1&techworker4_danger==1&employed2==1recode group4 (.=3) if techworker4==1&techworker4_nondanger==1&employed2==1recode group4 (.=1) if lawfinance==1&techworker4==0&employed2==1&danger==0recode group4 (.=1) if lawfinance==0&techworker4==0&employed2==1&danger==0recode group4 (.=1) if lawfinance==1&techworker4==0&employed2==1&danger==1recode group4 (.=1) if lawfinance==0&techworker4==0&employed2==1&danger==1ttest h1bvisas_scale if dscore!=.&race!=4&(group4==3|group4==1)&zipcode!=., by(group4) unequalg group5 = .recode group5 (.=1) if techworker4==1&techworker4_nondanger==1recode group5 (.=2) if employed2==1&danger==0&techworker4 == 0ttest h1bvisas_scale if dscore!=.&race!=4&(group5==2|group5==1)&zipcode!=., by(group5) unequal*******DIFFERENCE-OF-MEANS: INDIAN IMMIGRATION*******
ttest indianimmig_scale if dscore!=.&race!=4&(group_placz2==3|group_placz2==1)&zipcode!=., by(group_placz2) unequalttest indianimmig_scale if dscore!=.&race!=4&(group_placz2==3|group_placz2==2)&zipcode!=., by(group_placz2) unequalttest indianimmig_scale if dscore!=.&race!=4&(group_placz2==3|group_placz2==4)&zipcode!=., by(group_placz2) unequalttest indianimmig_scale if dscore!=.&race!=4&(group_placz2==3|group_placz2==1)&mediat==0&zipcode!=., by(group_placz2) unequalttest indianimmig_scale if dscore!=.&race!=4&(group_placz2==3|group_placz2==2)&mediat==0&zipcode!=., by(group_placz2) unequalttest indianimmig_scale if dscore!=.&race!=4&(group_placz2==3|group_placz2==4)&mediat==0&zipcode!=., by(group_placz2) unequalttest indianimmig_scale if dscore!=.&race!=4&zipcode!=., by(mediat) unequalttest indianimmig_scale if techworker4==0&dscore!=.&race!=4&zipcode!=., by(mediat) unequal******REGRESSIONS******gen agesq = age*age*** SAVE ***reg h1bvisas_scale groupcat2 groupcat1 dscore2   female age agesq married educ racewhite income2 pid  techzip2 if dscore!=.&race!=4&zipcode!=., cluster(zipcode)reg h1bvisas_scale groupcat2 groupcat1 dscore2  indian_traits threatened2  female age agesq married educ racewhite income2 pid  techzip2 if dscore!=.&race!=4&zipcode!=., cluster(zipcode)reg h1bvisas_scale group_placzcat23 group_placzcat22 group_placzcat21 dscore2   female age agesq married educ racewhite income2 pid  techzip2 if dscore!=.&race!=4&zipcode!=., cluster(zipcode)reg h1bvisas_scale group_placzcat23 group_placzcat22 group_placzcat21 dscore2  indian_traits threatened2  female age agesq married educ racewhite income2 pid  techzip2 if dscore!=.&race!=4&zipcode!=., cluster(zipcode)reg indianimmig_scale groupcat2 groupcat1 dscore2   female age agesq married educ racewhite income2 pid  techzip2 if dscore!=.&race!=4&zipcode!=., cluster(zipcode)reg indianimmig_scale groupcat2 groupcat1 dscore2  indian_traits threatened2  female age agesq married educ racewhite income2 pid  techzip2 if dscore!=.&race!=4&zipcode!=., cluster(zipcode)reg indianimmig_scale group_placzcat23 group_placzcat22 group_placzcat21 dscore2   female age agesq married educ racewhite income2 pid  techzip2 if dscore!=.&race!=4&zipcode!=., cluster(zipcode)reg indianimmig_scale group_placzcat23 group_placzcat22 group_placzcat21 dscore2  indian_traits threatened2  female age agesq married educ racewhite income2 pid  techzip2 if dscore!=.&race!=4&zipcode!=., cluster(zipcode)******ROBUSTNESS CHECKS******* With danger added
xi: reg h1bvisas_scale i.group3 dscore2   female age agesq married educ racewhite income2 pid  techzip2 if dscore!=.&race!=4&zipcode!=., cluster(zipcode)
reg h1bvisas_scale _Igroup3_* dscore2   female age agesq married educ racewhite income2 pid  techzip2 if dscore!=.&race!=4&zipcode!=., cluster(zipcode)reg h1bvisas_scale _Igroup3_* dscore2 indian_traits threatened2  female age agesq married educ racewhite income2 pid  techzip2 if dscore!=.&race!=4&zipcode!=., cluster(zipcode)reg indianimmig_scale _Igroup3_* dscore2   female age agesq married educ racewhite income2 pid  techzip2 if dscore!=.&race!=4&zipcode!=., cluster(zipcode)reg indianimmig_scale _Igroup3_* dscore2 indian_traits threatened2  female age agesq married educ racewhite income2 pid  techzip2 if dscore!=.&race!=4&zipcode!=., cluster(zipcode)* With education as a set of indicator variables
tab education, gen(ed_indicator)
reg h1bvisas_scale groupcat2 groupcat1 dscore2   female age agesq married ed_indicator2 ed_indicator3 ed_indicator4 ed_indicator5 ed_indicator6 racewhite income2 pid  techzip2 if dscore!=.&race!=4&zipcode!=., cluster(zipcode)reg h1bvisas_scale groupcat2 groupcat1 dscore2  indian_traits threatened2  female age agesq married ed_indicator2 ed_indicator3 ed_indicator4 ed_indicator5 ed_indicator6 racewhite income2 pid  techzip2 if dscore!=.&race!=4&zipcode!=., cluster(zipcode)reg h1bvisas_scale group_placzcat23 group_placzcat22 group_placzcat21 dscore2   female age agesq married ed_indicator2 ed_indicator3 ed_indicator4 ed_indicator5 ed_indicator6 racewhite income2 pid  techzip2 if dscore!=.&race!=4&zipcode!=., cluster(zipcode)reg h1bvisas_scale group_placzcat23 group_placzcat22 group_placzcat21 dscore2  indian_traits threatened2  female age agesq married ed_indicator2 ed_indicator3 ed_indicator4 ed_indicator5 ed_indicator6 racewhite income2 pid  techzip2 if dscore!=.&race!=4&zipcode!=., cluster(zipcode)reg indianimmig_scale groupcat2 groupcat1 dscore2   female age agesq married ed_indicator2 ed_indicator3 ed_indicator4 ed_indicator5 ed_indicator6 racewhite income2 pid  techzip2 if dscore!=.&race!=4&zipcode!=., cluster(zipcode)reg indianimmig_scale groupcat2 groupcat1 dscore2  indian_traits threatened2  female age agesq married ed_indicator2 ed_indicator3 ed_indicator4 ed_indicator5 ed_indicator6 racewhite income2 pid  techzip2 if dscore!=.&race!=4&zipcode!=., cluster(zipcode)reg indianimmig_scale group_placzcat23 group_placzcat22 group_placzcat21 dscore2   female age agesq married ed_indicator2 ed_indicator3 ed_indicator4 ed_indicator5 ed_indicator6 racewhite income2 pid  techzip2 if dscore!=.&race!=4&zipcode!=., cluster(zipcode)reg indianimmig_scale group_placzcat23 group_placzcat22 group_placzcat21 dscore2  indian_traits threatened2  female age agesq married ed_indicator2 ed_indicator3 ed_indicator4 ed_indicator5 ed_indicator6 racewhite income2 pid  techzip2 if dscore!=.&race!=4&zipcode!=., cluster(zipcode)* Placebo Comparisons (2a vs. 2b averages)
g dv1=h1bvisas_scale
g dv2=indianimmig_scale
gen id = caseid
order id
reshape long dv, i(id)
order id _j
g d=_j-1
g w_2 = groupcat2*d
g w_1 = groupcat1*d

reg dv groupcat2 groupcat1 w_2 w_1 d if dscore!=.&race!=4&zipcode!=., cluster(id)

test _b[d]=0, notest
test _b[w_2] = 0, accum




**********************APPENDIX****************************CREATE LABELS AND ADDITIONAL DEMOGRAPHIC VARIABLES******label define fem 0 "Male" 1 "Female"label val female femlabel define mar 1 "married" 0 "unmarried"label val married margen age_v2 = 2009-birthyearg age65plus = 1 if age_v2 >= 65 & age_v2 !=.recode age65plus (.=0) if age_v2 !=.label define age1 1 "age65" 0 "notage65"label val age65plus age1g age50to64 = 1 if age_v2 >= 50 & age_v2 <= 64 & age_v2 !=.recode age50to64 (.=0) if age_v2 !=.g age35to49 = 1 if age_v2 >= 35 & age_v2 <=49 & age_v2 !=.recode age35to49 (.=0) if age_v2 !=.label define age2 1 "age50to64" 0 "notage50to64"label val age50to64 age2label define age3 1 "age35to49" 0 "notage35to49"label val age35to49 age3g agecat = 2 if age35to49 == 1replace agecat = 3 if age50to64 == 1replace agecat = 4 if age65plus == 1recode agecat (.= 1) if age != .label define age5 1 "age18-34" 2 "age35to49" 3 "age50to64" 4 "age65plus"label val agecat age5
g hs_grad = 1 if education >= 1 & education != .recode hs_grad (.=0) if education == 0label define grad 0 "nograd" 1 "grad"label val hs_grad grad
tab racetab race if techzip2 == 1g p_white = 1 if race == 8recode p_white (.=0) if race != .label define white 0 "nonwhite" 1 "white"label val p_white whiteg p_black = 1 if race == 2recode p_black (.=0) if race != .label define black 0 "nonblack" 1 "black"label val p_black blackg p_asian = 1 if race == 1recode p_asian (.=0) if race != .label define asian 0 "nonasian" 1 "asian"label val p_asian asiang p_na = 1 if race == 7recode p_na (.=0) if race != .label define native 0 "nonnative" 1 "native"label val p_na native


*******TECHZIP*******tab techzip2 if dscore!=.&race!=4&zipcode!=.tab techworker4 if techzip2==1tab techworker4 if techzip2==1&(employed==1|employmentstatus == "Unemployed")tab techworker4 if techzip2==0tab techworker4 if techzip2==0&employed==1g employed3 = 1 if employmentstatus == "Full-time employee" | employmentstatus == "Part-time employee"svyset [pweight = weightvec]tab techworker4 if employed3 == 1svy: tab techworker4 if employed3 == 1tab techworker4 if techzip2 == 1 & employed3 == 1svy: tab techworker4 if techzip2 == 1 & employed3 == 1tab female 
svy: tab female tab female if techzip2 == 1 svy: tab female if techzip2 == 1 

tab married 
svy: tab married tab married if techzip2 == 1 svy: tab married if techzip2 == 1 

tab hs_grad
svy: tab hs_gradtab hs_grad if techzip2 == 1 svy: tab hs_grad if techzip2 == 1 

tab p_white
svy: tab p_whitetab p_white if techzip2 == 1 svy: tab p_white if techzip2 == 1 

tab agecat
svy: tab agecattab agecat if techzip2 == 1 svy: tab agecat if techzip2 == 1 

*******DESCRIPTIVES*******g age2 = 2009-birthyearrecode age2 (109=90)su h1bvisas indianimmig techworker4 group_placzcat21- group_placzcat24 dscore indian_traits threatened age2  female married partyid education racewhite techzip2 if dscore!=.&race!=4&zipcode!=.su income if dscore!=.&race!=4&income<=9&zipcode!=.


******REGRESSIONS (DROP POST-TREATMENT MEASURES)******reg h1bvisas_scale groupcat2 groupcat1 dscore2 female age agesq married educ racewhite income2 pid  techzip2 if dscore!=.&race!=4&zipcode!=., cluster(zipcode)reg h1bvisas_scale groupcat2 groupcat1 female age agesq married educ racewhite income2 pid techzip2 if dscore!=.&race!=4&zipcode!=., cluster(zipcode)reg h1bvisas_scale groupcat2 groupcat1 female age agesq married racewhite educ pid if dscore!=.&race!=4&zipcode!=., cluster(zipcode)reg h1bvisas_scale groupcat2 groupcat1 female age agesq married racewhite educ if dscore!=.&race!=4&zipcode!=., cluster(zipcode)reg indianimmig_scale groupcat2 groupcat1 dscore2 female age agesq married educ racewhite income2 pid  techzip2 if dscore!=.&race!=4&zipcode!=., cluster(zipcode)reg indianimmig_scale groupcat2 groupcat1 female age agesq married educ racewhite income2 pid techzip2 if dscore!=.&race!=4&zipcode!=., cluster(zipcode)reg indianimmig_scale groupcat2 groupcat1 female age agesq married educ racewhite pid if dscore!=.&race!=4&zipcode!=., cluster(zipcode)reg indianimmig_scale groupcat2 groupcat1 female age agesq married educ racewhite if dscore!=.&race!=4&zipcode!=., cluster(zipcode)******REGRESSIONS WITH WEIGHTS ******reg h1bvisas_scale groupcat2 groupcat1 dscore2 female age agesq married educ racewhite income2 pid  techzip2 if dscore!=.&race!=4 [pweight = weightvec], cluster(zipcode)reg h1bvisas_scale groupcat2 groupcat1 dscore2 indian_traits threatened2  female age agesq married educ racewhite income2 pid  techzip2 if dscore!=.&race!=4 [pweight = weightvec], cluster(zipcode)reg h1bvisas_scale group_placzcat23 group_placzcat22 group_placzcat21 dscore2   female age agesq married educ racewhite income2 pid  techzip2 if dscore!=.&race!=4 [pweight = weightvec], cluster(zipcode)reg h1bvisas_scale group_placzcat23 group_placzcat22 group_placzcat21 dscore2  indian_traits threatened2  female age agesq married educ racewhite income2 pid  techzip2 if dscore!=.&race!=4 [pweight = weightvec], cluster(zipcode)reg indianimmig_scale groupcat2 groupcat1 dscore2 female age agesq married educ racewhite income2 pid  techzip2 if dscore!=.&race!=4 [pweight = weightvec], cluster(zipcode)reg indianimmig_scale groupcat2 groupcat1 dscore2 indian_traits threatened2  female age agesq married educ racewhite income2 pid  techzip2 if dscore!=.&race!=4 [pweight = weightvec], cluster(zipcode)reg indianimmig_scale group_placzcat23 group_placzcat22 group_placzcat21 dscore2   female age agesq married educ racewhite income2 pid  techzip2 if dscore!=.&race!=4 [pweight = weightvec], cluster(zipcode)reg indianimmig_scale group_placzcat23 group_placzcat22 group_placzcat21 dscore2  indian_traits threatened2  female age agesq married educ racewhite income2 pid  techzip2 if dscore!=.&race!=4 [pweight = weightvec], cluster(zipcode)******WEIGHTED DIFFERENCE-IN-MEANS ******
svyset [pweight = weightvec]g group_placz2_31 = 1 if group_placz2 == 3replace group_placz2_31 = 0 if group_placz2 == 1* (a)svy: mean h1bvisas_scale if dscore!=.&race!=4&(group_placz2==3|group_placz2==1), over(group_placz2_31)svy: reg h1bvisas_scale group_placz2_31 if dscore!=.&race!=4&(group_placz2==3|group_placz2==1)predict fig3 if group_placz2 == 3 &dscore!=.&race!=4&(group_placz2==3|group_placz2==1)predict fig1 if group_placz2 == 1 &dscore!=.&race!=4&(group_placz2==3|group_placz2==1)predict fig3_se if group_placz2 == 3 &dscore!=.&race!=4&(group_placz2==3|group_placz2==1), stdppredict fig1_se if group_placz2 == 1 &dscore!=.&race!=4&(group_placz2==3|group_placz2==1), stdpegen n3 = count(fig3) if dscore!=.&race!=4&(group_placz2==3|group_placz2==1)&group_placz2==3egen n1 = count(fig1) if dscore!=.&race!=4&(group_placz2==3|group_placz2==1)&group_placz2==1g fig3_lgth_ssb = invttail(n3-1,0.05)*(fig3_se)/(sqrt(2)) if dscore!=.&race!=4 & group_placz2 == 3g fig1_lgth_ssb = invttail(n1-1,0.05)*(fig1_se)/(sqrt(2)) if dscore!=.&race!=4 & group_placz2 == 1svy: reg h1bvisas_scale group_placz2 if dscore!=.&race!=4&(group_placz2==3|group_placz2==2)predict fig2 if group_placz2 == 2predict fig2_se if group_placz2 == 2, stdpegen n2 = count(fig2) if dscore!=.&race!=4&(group_placz2==3|group_placz2==2)&group_placz2==2g fig2_lgth_ssb = invttail(n2-1,0.05)*(fig2_se)/(sqrt(2)) if dscore!=.&race!=4 & group_placz2 == 2svy: reg h1bvisas_scale group_placz2 if dscore!=.&race!=4&(group_placz2==3|group_placz2==4)predict fig4 if group_placz2 == 4predict fig4_se if group_placz2 == 4, stdpegen n4 = count(fig4) if dscore!=.&race!=4&(group_placz2==3|group_placz2==4)&group_placz2==4g fig4_lgth_ssb = invttail(n4-1,0.05)*(fig4_se)/(sqrt(2)) if dscore!=.&race!=4 & group_placz2 == 4su fig* drop fig* n4 n3 n2 n1svy: mean h1bvisas_scale if dscore!=.&race!=4&(group_placz2==3|group_placz2==1)&mediat==0, over(group_placz2_31)svy: reg h1bvisas_scale group_placz2_31 if dscore!=.&race!=4&(group_placz2==3|group_placz2==1)&mediat==0predict fig3 if group_placz2 == 3 &dscore!=.&race!=4&(group_placz2==3|group_placz2==1)&mediat==0predict fig1 if group_placz2 == 1 &dscore!=.&race!=4&(group_placz2==3|group_placz2==1)&mediat==0predict fig3_se if group_placz2 == 3 &dscore!=.&race!=4&(group_placz2==3|group_placz2==1)&mediat==0, stdppredict fig1_se if group_placz2 == 1 &dscore!=.&race!=4&(group_placz2==3|group_placz2==1)&mediat==0, stdpegen n3 = count(fig3) if dscore!=.&race!=4&(group_placz2==3|group_placz2==1)&group_placz2==3&mediat==0egen n1 = count(fig1) if dscore!=.&race!=4&(group_placz2==3|group_placz2==1)&group_placz2==1&mediat==0g fig3_lgth_ssb = invttail(n3-1,0.05)*(fig3_se)/(sqrt(2)) if dscore!=.&race!=4 & group_placz2 == 3&mediat==0g fig1_lgth_ssb = invttail(n1-1,0.05)*(fig1_se)/(sqrt(2)) if dscore!=.&race!=4 & group_placz2 == 1&mediat==0svy: reg h1bvisas_scale group_placz2 if dscore!=.&race!=4&(group_placz2==3|group_placz2==2)&mediat==0predict fig2 if group_placz2 == 2&mediat==0predict fig2_se if group_placz2 == 2&mediat==0, stdpegen n2 = count(fig2) if dscore!=.&race!=4&(group_placz2==3|group_placz2==2)&group_placz2==2&mediat==0g fig2_lgth_ssb = invttail(n2-1,0.05)*(fig2_se)/(sqrt(2)) if dscore!=.&race!=4 & group_placz2 == 2&mediat==0svy: reg h1bvisas_scale group_placz2 if dscore!=.&race!=4&(group_placz2==3|group_placz2==4)&mediat==0predict fig4 if group_placz2 == 4&mediat==0predict fig4_se if group_placz2 == 4&mediat==0, stdpegen n4 = count(fig4) if dscore!=.&race!=4&(group_placz2==3|group_placz2==4)&group_placz2==4&mediat==0g fig4_lgth_ssb = invttail(n4-1,0.05)*(fig4_se)/(sqrt(2)) if dscore!=.&race!=4 & group_placz2 == 4&mediat==0su fig* drop fig* n4 n3 n2 n1* (b)svy: mean indianimmig_scale if dscore!=.&race!=4&(group_placz2==3|group_placz2==1), over(group_placz2_31)svy: reg indianimmig_scale group_placz2_31 if dscore!=.&race!=4&(group_placz2==3|group_placz2==1)predict fig3 if group_placz2 == 3 &dscore!=.&race!=4&(group_placz2==3|group_placz2==1)predict fig1 if group_placz2 == 1 &dscore!=.&race!=4&(group_placz2==3|group_placz2==1)predict fig3_se if group_placz2 == 3 &dscore!=.&race!=4&(group_placz2==3|group_placz2==1), stdppredict fig1_se if group_placz2 == 1 &dscore!=.&race!=4&(group_placz2==3|group_placz2==1), stdpegen n3 = count(fig3) if dscore!=.&race!=4&(group_placz2==3|group_placz2==1)&group_placz2==3egen n1 = count(fig1) if dscore!=.&race!=4&(group_placz2==3|group_placz2==1)&group_placz2==1g fig3_lgth_ssb = invttail(n3-1,0.05)*(fig3_se)/(sqrt(2)) if dscore!=.&race!=4 & group_placz2 == 3g fig1_lgth_ssb = invttail(n1-1,0.05)*(fig1_se)/(sqrt(2)) if dscore!=.&race!=4 & group_placz2 == 1svy: reg indianimmig_scale group_placz2 if dscore!=.&race!=4&(group_placz2==3|group_placz2==2)predict fig2 if group_placz2 == 2predict fig2_se if group_placz2 == 2, stdpegen n2 = count(fig2) if dscore!=.&race!=4&(group_placz2==3|group_placz2==2)&group_placz2==2g fig2_lgth_ssb = invttail(n2-1,0.05)*(fig2_se)/(sqrt(2)) if dscore!=.&race!=4 & group_placz2 == 2svy: reg indianimmig_scale group_placz2 if dscore!=.&race!=4&(group_placz2==3|group_placz2==4)predict fig4 if group_placz2 == 4predict fig4_se if group_placz2 == 4, stdpegen n4 = count(fig4) if dscore!=.&race!=4&(group_placz2==3|group_placz2==4)&group_placz2==4g fig4_lgth_ssb = invttail(n4-1,0.05)*(fig4_se)/(sqrt(2)) if dscore!=.&race!=4 & group_placz2 == 4su fig* drop fig* n4 n3 n2 n1svy: mean indianimmig_scale if dscore!=.&race!=4&(group_placz2==3|group_placz2==1)&mediat==0, over(group_placz2_31)svy: reg indianimmig_scale group_placz2_31 if dscore!=.&race!=4&(group_placz2==3|group_placz2==1)&mediat==0predict fig3 if group_placz2 == 3 &dscore!=.&race!=4&(group_placz2==3|group_placz2==1)&mediat==0predict fig1 if group_placz2 == 1 &dscore!=.&race!=4&(group_placz2==3|group_placz2==1)&mediat==0predict fig3_se if group_placz2 == 3 &dscore!=.&race!=4&(group_placz2==3|group_placz2==1)&mediat==0, stdppredict fig1_se if group_placz2 == 1 &dscore!=.&race!=4&(group_placz2==3|group_placz2==1)&mediat==0, stdpegen n3 = count(fig3) if dscore!=.&race!=4&(group_placz2==3|group_placz2==1)&group_placz2==3&mediat==0egen n1 = count(fig1) if dscore!=.&race!=4&(group_placz2==3|group_placz2==1)&group_placz2==1&mediat==0g fig3_lgth_ssb = invttail(n3-1,0.05)*(fig3_se)/(sqrt(2)) if dscore!=.&race!=4 & group_placz2 == 3&mediat==0g fig1_lgth_ssb = invttail(n1-1,0.05)*(fig1_se)/(sqrt(2)) if dscore!=.&race!=4 & group_placz2 == 1&mediat==0svy: reg indianimmig_scale group_placz2 if dscore!=.&race!=4&(group_placz2==3|group_placz2==2)&mediat==0predict fig2 if group_placz2 == 2&mediat==0predict fig2_se if group_placz2 == 2&mediat==0, stdpegen n2 = count(fig2) if dscore!=.&race!=4&(group_placz2==3|group_placz2==2)&group_placz2==2&mediat==0g fig2_lgth_ssb = invttail(n2-1,0.05)*(fig2_se)/(sqrt(2)) if dscore!=.&race!=4 & group_placz2 == 2&mediat==0svy: reg indianimmig_scale group_placz2 if dscore!=.&race!=4&(group_placz2==3|group_placz2==4)&mediat==0predict fig4 if group_placz2 == 4&mediat==0predict fig4_se if group_placz2 == 4&mediat==0, stdpegen n4 = count(fig4) if dscore!=.&race!=4&(group_placz2==3|group_placz2==4)&group_placz2==4&mediat==0g fig4_lgth_ssb = invttail(n4-1,0.05)*(fig4_se)/(sqrt(2)) if dscore!=.&race!=4 & group_placz2 == 4&mediat==0su fig* drop fig* n4 n3 n2 n1* (c)svy: reg h1bvisas_scale mediat if dscore!=.&race!=4predict figmediat1 if mediat == 1predict figmediat1_se if mediat == 1, stdppredict figmediat0 if mediat == 0predict figmediat0_se if mediat == 0, stdpegen n1 = count(figmediat1) if dscore!=.&race!=4egen n0 = count(figmediat0) if dscore!=.&race!=4g figmediat1_lgth_ssb = invttail(n1-1,0.05)*(figmediat1_se)/(sqrt(2)) if dscore!=.&race!=4g figmediat0_lgth_ssb = invttail(n0-1,0.05)*(figmediat0_se)/(sqrt(2)) if dscore!=.&race!=4su figmediat*drop figmediat* n4 n3 n2 n1svy: reg h1bvisas_scale mediat if techworker4==0&dscore!=.&race!=4predict figmediat1 if mediat == 1predict figmediat1_se if mediat == 1, stdppredict figmediat0 if mediat == 0predict figmediat0_se if mediat == 0, stdpegen n1 = count(figmediat1) if dscore!=.&race!=4egen n0 = count(figmediat0) if dscore!=.&race!=4g figmediat1_lgth_ssb = invttail(n1-1,0.05)*(figmediat1_se)/(sqrt(2)) if dscore!=.&race!=4g figmediat0_lgth_ssb = invttail(n0-1,0.05)*(figmediat0_se)/(sqrt(2)) if dscore!=.&race!=4su figmediat*drop figmediat* n4 n3 n2 n1* (d)svy: reg indianimmig_scale mediat if dscore!=.&race!=4predict figmediat1 if mediat == 1predict figmediat1_se if mediat == 1, stdppredict figmediat0 if mediat == 0predict figmediat0_se if mediat == 0, stdpegen n1 = count(figmediat1) if dscore!=.&race!=4egen n0 = count(figmediat0) if dscore!=.&race!=4g figmediat1_lgth_ssb = invttail(n1-1,0.05)*(figmediat1_se)/(sqrt(2)) if dscore!=.&race!=4g figmediat0_lgth_ssb = invttail(n0-1,0.05)*(figmediat0_se)/(sqrt(2)) if dscore!=.&race!=4su figmediat*drop figmediat* n4 n3 n2 n1
svy: reg indianimmig_scale mediat if techworker4==0&dscore!=.&race!=4predict figmediat1 if mediat == 1predict figmediat1_se if mediat == 1, stdppredict figmediat0 if mediat == 0predict figmediat0_se if mediat == 0, stdpegen n1 = count(figmediat1) if dscore!=.&race!=4egen n0 = count(figmediat0) if dscore!=.&race!=4g figmediat1_lgth_ssb = invttail(n1-1,0.05)*(figmediat1_se)/(sqrt(2)) if dscore!=.&race!=4g figmediat0_lgth_ssb = invttail(n0-1,0.05)*(figmediat0_se)/(sqrt(2)) if dscore!=.&race!=4su figmediat* n4 n3 n2 n1******DEMOGRAPHICS:CENSUS (Table A3 (Columns 3&6))******* Row 1 computations in TechZips.xls
* Column 6 drawn from Census documents for 2010 (www.census.gov)
* Census Data for FIPS in Study Sample
use census.dta, clear
* Genderg female = sex20/100g female_pop = pop010200 * femaleegen totalpop = sum(pop010200)egen totalfempop = sum(female_pop)g fem_share = totalfempop/totalpopegen totalpop2 = sum(pop010200) if techzip == 1egen totalfempop2 = sum(female_pop) if techzip == 1g fem_share2 = totalfempop2/totalpop2su fem_share fem_share2* Marital Statusg married = maritalstatus/100g married_pop = pop010200 * maritalstatusegen totalmarpop = sum(married_pop)g married_share = totalmarpop/totalpopegen totalmarpop2 = sum(married_pop) if techzip == 1g married_share2 = totalmarpop2/totalpop2su married_share married_share2* Raceg white = rhi805210/100g white2 = rhi105210/100g hispanic = rhi705210/100g black = rhi205210/100g na = rhi305210/100g asian = rhi405210/100g mixed = rhi605210/100foreach var in white white2 hispanic black na asian mixed{g `var'_pop = pop010200 * `var'egen total`var'pop = sum(`var'_pop)g `var'_share = total`var'pop/totalpopegen total`var'pop2 = sum(`var'_pop) if techzip == 1g `var'_share2 = total`var'pop2/totalpop2 su `var'_share `var'_share2}* Age** Of those over 18, % that are 65+g over65_condl18 = (age765210)/(100-(100-age18plusp))g over65_pop = pop010200 * over65_condl18egen totalover65pop = sum(over65_pop)g over65_share = totalover65pop/totalpopegen totalover65pop2 = sum(over65_pop) if techzip == 1g over65_share2 = totalover65pop2/totalpop2su over65_share over65_share2** Of those over 18, % that are 50 - 64g age50to64 = age50to54p+ age55to59p+ age60to64pg age50to64_condl18 = age50to64/(100-(100-age18plusp))g age50to64_pop = pop010200 * age50to64_condl18 egen total50to64pop= sum(age50to64_pop)g age50to64_share = total50to64pop/totalpopegen total50to64pop2= sum(age50to64_pop) if techzip == 1g age50to64_share2 = total50to64pop2/totalpop2su age50to64_share age50to64_share2** Of those over 18, % that are 35 - 49g age35to49 = age35to39p+age40to44p+ ag45to49pg age35to49_condl18 = age35to49/(100-(100-age18plusp))g age35to49_pop = pop010200 * age35to49_condl18 egen total35to49pop= sum(age35to49_pop)g age35to49_share = total35to49pop/totalpopegen total35to49pop2= sum(age35to49_pop) if techzip == 1g age35to49_share2 = total35to49pop2/totalpop2su age35to49_share age35to49_share2**********************VISA EXPERIMENT**********************
use globalization_exp.dta

******DEFINING VARIABLES******
g white = 1 if q4 == 1
recode white (.=0) if q4 !=.
g male = q1-1
g age = 2009-(1900+q2)
g age2 = (age-18)/(109-18)
g educ = (q5-1)/5
g partyid = 1 if q7 == 1 & q7a == 1
replace partyid = 2 if q7 == 1 & q7a == 2
replace partyid = 2 if q7 == 1 & q7a == 99999999
replace partyid = 3 if q7 == 3 & q7b == 1
replace partyid = 3 if q7 == 4 & q7b == 1
replace partyid = 4 if q7 == 3 & q7b == 99999999
replace partyid = 4 if q7 == 4 & q7b == 99999999
replace partyid = 4 if q7 == 99999999
replace partyid = 5 if q7 == 4 & q7b == 2
replace partyid = 5 if q7 == 3 & q7b == 2
replace partyid = 6 if q7 == 2 & q7a == 99999999
replace partyid = 6 if q7 == 2 & q7a == 2
replace partyid = 7 if q7 == 2 & q7a == 1
g partyidb = (7-partyid)/6
g culthreaty = q22>4 if q22<6g canadian_culthreaty = canadian*culthreatyg russian_culthreaty = russian*culthreatyegen visasupport = rowtotal(m1t1q1 m1t2q1 m1t3q1)replace visasupport = . if visasupport == 0g visasupport_scale = (visasupport-5)/-4 if visasupport<6******RESULTS******* "decrease a little" = 4 & "decrease a great deal" = 5tab visasupport if canadian==1&culthreaty!=.tab visasupport if russian==1&culthreaty!=.tab visasupport if indian==1&culthreaty!=.* Difference-in-Means
g category = .
recode category (.=1) if canadian == 1
recode category (.=2) if russian == 1
recode category (.=3) if indian == 1

tab category if m1t4q1==.&m1t5q1==.&m1t6q1==.&culthreaty!=.
ttest visasupport_scale if (canadian==1|russian==1)&culthreaty!=., by(category)ttest visasupport_scale if (canadian==1|indian==1)&culthreaty!=., by(category)ttest visasupport_scale if (russian==1|indian==1)&culthreaty!=., by(category)ttest visasupport_scale if (canadian==1|russian==1)&culthreaty==1, by(category)ttest visasupport_scale if (canadian==1|indian==1)&culthreaty==1, by(category)ttest visasupport_scale if (russian==1|indian==1)&culthreaty==1, by(category)ttest visasupport_scale if (canadian==1|russian==1)&culthreaty==0, by(category)ttest visasupport_scale if (canadian==1|indian==1)&culthreaty==0, by(category)ttest visasupport_scale if (russian==1|indian==1)&culthreaty==0, by(category)* Standard Error Bars
sort categoryby category: egen meanexp = mean(visasupport_scale) if culthreaty!=.by category: egen sdexp = sd(visasupport_scale) if culthreaty!=.by category: egen n_exp = count(visasupport_scale) if culthreaty!=.gen hiexp = meanexp + invttail(n_exp-1,0.05)*(sdexp / sqrt(n_exp)) if culthreaty!=.gen loexp = meanexp - invttail(n_exp-1,0.05)*(sdexp / sqrt(n_exp)) if culthreaty!=.gen exp_lgth = invttail(n_exp-1,0.05)*(sdexp / sqrt(n_exp)) if culthreaty!=.gen exp_lgth_ssb = (invttail(n_exp-1,0.05)*(sdexp / sqrt(n_exp)))/sqrt(2) if culthreaty!=.by category: su meanexp exp_lgth exp_lgth_ssbby category: egen meanexp2 = mean(visasupport_scale) if culthreaty==1by category: egen sdexp2 = sd(visasupport_scale) if culthreaty ==1by category: egen n_exp2 = count(visasupport_scale) if culthreaty==1gen hiexp2 = meanexp2 + invttail(n_exp2-1,0.05)*(sdexp2 / sqrt(n_exp2)) if culthreaty ==1gen loexp2 = meanexp2 - invttail(n_exp2-1,0.05)*(sdexp2 / sqrt(n_exp2)) if culthreaty ==1gen exp_lgth2 = invttail(n_exp2-1,0.05)*(sdexp2 / sqrt(n_exp2)) if culthreaty ==1gen exp_lgth_ssb2 = (invttail(n_exp2-1,0.05)*(sdexp2 / sqrt(n_exp2)))/sqrt(2) if culthreaty ==1by category: su meanexp2 exp_lgth2 exp_lgth_ssb2by category: egen meanexp3 = mean(visasupport_scale) if culthreaty ==0by category: egen sdexp3 = sd(visasupport_scale) if culthreaty ==0by category: egen n_exp3 = count(visasupport_scale) if culthreaty ==0gen hiexp3 = meanexp3 + invttail(n_exp3-1,0.05)*(sdexp3 / sqrt(n_exp3)) if culthreaty ==0gen loexp3 = meanexp3 - invttail(n_exp3-1,0.05)*(sdexp3 / sqrt(n_exp3)) if culthreaty ==0gen exp3_lgth = invttail(n_exp3-1,0.05)*(sdexp3 / sqrt(n_exp3)) if culthreaty ==0gen exp3_lgth_ssb = (invttail(n_exp3-1,0.05)*(sdexp3 / sqrt(n_exp3)))/sqrt(2) if culthreaty ==0by category: su meanexp3 exp3_lgth exp3_lgth_ssb* Regressionologit visasupport_scale canadian russian culthreaty canadian_culthreaty russian_culthreaty age2 male educ white partyidbtest canadian_culthreaty = russian_culthreaty